@extends('WShop::layout')
@section('content')
    @include('WShop::public.header')
    @component('WShop::public.header')
        @slot('page_title'){{$page_title}} @endslot
        @slot('btn')
            <a href="{{route('f_Wap_Account_wdApply')}}" class="mui-pull-right mui-text-bai" style="margin-top: 12px;font-size: 12px;">我的提现</a>
        @endslot
    @endcomponent
    <div class="mui-content mui-scroll-wrapper" id="pullrefresh">
        <div class="mui-scroll">
                <div class="mui-zhuda" style="padding-top: 10px;">
                    <div class="mui-dingdan-list">
                        @if($list->isNotEmpty())
                            <ul class="mui-list-unstyled mui-clearfix" id="pull-load">
                                @foreach($list as $item)
                                    <li class="bg-fff">
                                        <div class="dingdan-list-header">申请时间：{{$item->created_at}}
                                            @switch($item->status)
                                                @case(0)
                                                <span class="mui-pull-right mui-text-blue">待审批</span>
                                                @break
                                                @case(1)
                                                <span class="mui-pull-right mui-text-gren">已同意</span>
                                                @break
                                                @default
                                                <span class="mui-pull-right mui-text-red">被驳回</span>
                                            @endswitch
                                        </div>
                                        <div class="flex">
                                           {{-- <img src="{{$goods->goods_img}}" alt="" />--}}

                                            <div class="flex-right" style="width: 100%;">
                                                @if($item->status!=0)
                                                <div class="flex">
                                                    <div class="mui-ellipsis-2 mui-text-red">备注:{{$item->handle_remark ?? ''}}</div>
                                                </div>
                                                @endif
                                                <div>
                                                    <div style="padding-left: 10px;color: #999;">{!! format_json($item->to_account) !!}</div>
                                                    <div style="padding-left: 10px"><span style="margin-right: 50px;">申请金额:￥{{$item->money+$item->service_fee}}</span></div>
                                                    <div style="padding-left: 10px"><span style="margin-right: 50px;">手续费:￥{{$item->service_fee}}</span></div>
                                                    <div style="padding-left: 10px"><span style="margin-right: 50px;">实发金额:￥{{$item->money}}</span></div>
                                                </div>
                                            </div>
                                        </div>
                                        @if($item->status!=0)
                                        <div class="mui-text-right"></div>
                                        <div class="mui-text-left"><span>审核时间：{{$item->handled_at}}</span></div>
                                        @endif
                                    </li>
                                @endforeach
                            </ul>
                        @else
                            <div style="height: 110px;"></div>
                            <div class="mui-text-center">
                                <img src="{{asset(config('mall.wap_assets1').'/images/empty.png')}}" alt="" width="200">
                                <p style="margin-top: 50px;"><a href="javascript:void(0);" style="color: #fff;border: 1px solid #8a96a2;padding: 8px 24px;border-radius: 16px;background: #8a96a2;">暂无数据</a></p>
                            </div>
                        @endif
                    </div>
                </div>

            </div>
        </div>
    </div>
    @include('WShop::public.foot_bar',['active'=>'user'])
@endsection
@push('scripts')
    <script src="{{asset(config('view.plugin').'/other/day.js')}}"></script>
    <script src="{{asset(config('view.frontend.wap_login').'/js/pull-loading.js')}}"></script>
    <script>
        pullLoading.tpl = '<li class="bg-fff">' +
            '       <div class="dingdan-list-header">申请时间：{%created_at%}<span class="mui-pull-right mui-text-{%color%}">{%status%}</span></div>' +
            '<div class="flex">' +
            ' <div class="flex-right" style="width: 100%;">{%handle_remark%}<div>' +
            '           <div style="padding-left: 10px;color: #999;">{%account%}</div>' +
            '            <div style="padding-left: 10px"><span style="margin-right: 50px;">申请金额：￥{%money%}</span></div>\n' +
            '            <div style="padding-left: 10px"><span style="margin-right: 50px;">手续费：￥{%service_fee%}</span></div>\n' +
            '            <div style="padding-left: 10px"><span style="margin-right: 50px;">实发金额：￥{%realmoney%}</span></div>\n' +

            '</div></div></div>{%handled_at%}</li>';

        pullLoading.load(function (data) {
            var statusText = {"-1":{"text":"被驳回","color":"red"},"0":{"text":"待审批","color":"blue"},"1":{"text":"已通过","color":"green"}}
            var len = data.length;
            for (var i=0; i<len; i++){
                var dateObj = dayjs(data[i]['created_at']*1000);
                if(data[i]['status']!=0){
                    var handleRemark = '<div class="flex"><div class="mui-ellipsis-2  mui-text-red">备注:'+data[i]['handle_remark']+'</div></div>';
                    var handleAt = '<div class="mui-text-right"></div><div class="mui-text-left"><span>审核时间:'+dayjs(parseInt(data[i]['handled_at'])*1000).format('YYYY-MM-DD HH:mm:ss')+'</span></div>'
                }else{
                    var handleAt = '';
                    var handleRemark = '';
                }
                var account = '';
                var true_money = 0;
                if(data[i]['to_account']!=''&&data[i]['to_account']!=undefined){
                    var toAccount = JSON.parse(data[i]['to_account']);
                    for (var index in toAccount){
                        account +=index+':'+toAccount[index]+'<br/>';
                    }
                }

                var itemTpl =pullLoading.tpl;
                var true_money = 0;
                true_money = data[i]['money'] + data[i]['service_fee'] ;
                itemTpl = itemTpl.replace('{%created_at%}',dateObj.format('YYYY-MM-DD HH:mm:ss'))
                    .replace('{%handle_remark%}',handleRemark)
                    .replace('{%status%}',statusText[data[i]['status']]['text'])
                    .replace('{%color%}',statusText[data[i]['status']]['color'])
                    .replace('{%account%}',account)
                    .replace('{%money%}',true_money)
                    .replace('{%realmoney%}', data[i]['money'])
                    .replace('{%service_fee%}',data[i]['service_fee'])
                    .replace('{%handled_at%}',handleAt);
                $("#pull-load").append(itemTpl);
            }
        })
    </script>
@endpush